<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="utf-8">
    <title>成品信息查询</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <meta content="0" http-equiv="Expires"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="Expires" content="0">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <meta http-equiv="Cache" content="no-cache">
    <link rel="stylesheet" href="../styles/base.css"/>
    <link rel="stylesheet" href="../styles/common.css"/>
    <link rel="stylesheet" href="../styles/font/iconfont.css"/>
    <link rel="stylesheet" href="../jqueryNicepage/css/layui.css"  media="all">
    <link rel="stylesheet" href="../styles/pages/calendar.css">
    <style>
        .body{
            background:#ddecf5;min-width: 1200px;
            overflow-x: hidden;
        }
        .seachHeader {
            width:100%;
            height:auto;
            clear: both;
            padding-bottom: 10px;
        }
        .seachHeader span{
            margin-top: 5px;
            float: left;
            display: inline-block;
            height:30px;
            line-height: 30px;
            font-size: 16px;

        }
        .seachHeader span:first-child{
            margin-left: 20px;
        }
        .seachHeader .inputBox{
            float:left;
            width:200px;
            height:30px;
            line-height: 30px;
            margin-left:-10px;
            font-size: 14px;
            padding-left: 10px;
            position: relative;
        }
        .seachHeader .inputBox input{
            width:190px;
            height:30px;
            line-height: 30px;
            position: absolute;
            padding-left: 10px;
            left:0;
        }
        .searchSureButton,.searchSureBtn{
            margin-left: 10px;
            float:right;
            background-color: #eee;
            font-family: 'Open Sans', sans-serif;
            font-size: 14px;
            text-decoration: none;
            font-weight: 600;
            color: #333;
            position: relative;
            padding: 1px 15px;
           /* margin-right: 15px;*/
            margin-top:2px;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px;
            background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0, rgb(242,242,242)), color-stop(1, rgb(242,242,242)) );
            cursor: pointer;
            overflow: hidden;
        }
        .searchSureButton:hover,.searchSureBtn:hover{
            color:#fff;
            background:#40E0D0;
        }
        .searchContainer{
            width:98%;
            max-height: 96%;
            min-height: 96%;
            margin-left: 1%;
            margin-top: 10px;
            min-width: 1200px;
            position:relative;
        }
        .centerInput{
            margin-right: 10px;
        }
        .td0 a{
            color:#0000FF;
            cursor: pointer;
            text-decoration:underline;
        }

        .addCuloumn{
            width:30px;
            height:100%;
            font-size: 20px;
            line-height: 30px;
        }
        .seachHeader ul{
            width:85%;
            height:auto;
        }
        .seachHeader ul li{
            height: 40px;
            width: auto;
            float: left;
        }
        .seachHeader ul .title{
            width:100px;
            text-align: left;
        }
        .seachHeader ul li .deleteItem{
            line-height: 35px;
        }
        .formContent{
            height:auto;
           /* position:relative;*/
            /*overflow-y: scroll;*/
        }
        .formContent center{
            margin-top: -10px;
        }
        .selectedBox{
            width:90px;
            height:auto;
            position: absolute;
            border:1px solid #ccc;
            cursor: pointer;
            overflow: hidden;
            z-index: 9999999;
            background: #fff;
            display:none;
            padding: 10px 0;
        }
        .selectedBox p{
            width:100%;
            height:30px;
            line-height: 30px;
            font-size: 14px;
            border-bottom: 1px solid #ccc;
            padding-left: 10px;

        }
        .selectedBox p:last-child{
            border-bottom:0;
        }
        .selectedBox p:hover{
            background:#5FB878;
        }
        .formContent center #pageBar2{
            position:absolute;
            bottom:10px;
            width:100%;
            text-align: center;
            display:none;
        }
        .layui-form {
            width: 322px;
            margin-top: -5px;
            margin-left: -120px;
        }
    </style>

</head>
<body class="body">
<div id="loading">
    <img src='../styles/img/loading.gif' />
</div>
<div class="searchContainer">
    <div class="seachHeader">
        <ul>
            <li>
                <span class="title">RFQ编号：</span>
                <span data-v="partRFQNumber" class="centerInput centerInput1"></span>
                <span><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></span>
            </li>
            <li>
                <span class="title">显示模式：</span>
                <span data-v="finishedGoodDisplayMode" class="centerInput centerInput2"><form class="layui-form layform3" action=""> <div class="layui-form-item proSelect"> <div class="layui-input-block editWidth"> <select class="select1" name="" lay-verify="" lay-filter="select1"> <option value=""></option> </select> </div> </div></form></span>
                <span><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></span>
            </li>

        </ul>
        <span class="rightEle"><div class="searchSureButton ">搜索</div></span>
        <span class="rightEle"><i title="增加一条输入条件" class="iconfont addCuloumn">&#xe601;</i>
            <div class="selectedBox">

            </div>
            </span>
        <div style="clear: both">

        </div>

    </div>
    <div class="formContent">
    </div>
</div>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script src="../js/json2.js"></script>
<script src="../js/common/publicClass.js"></script>
<script src="../layer/layer.js" charset="utf-8"></script>
<script type="text/javascript" src="../js/constants/calendar.js"></script>
<script type="text/javascript" src="../js/common/utils.js"></script>
<script type="text/javascript" src="../js/common/myAjax.js"></script>
<script type="text/javascript" src="../js/common/common.js"></script>
<script language="Javascript" src="../jqueryNicepage/js/layui.js"></script>
<script>
    maximizeWindow();//设置屏幕大小
    var searchInputArr=commonObj.pmlProductSeacrchList;//common.js配置的输入条件；
    $(".centerInput1").append(setInput("请输入RFQ编号","",50,"text"));
   MaterialReverseAjax("/MaterialAttService/getFinishedGoodDisplayMode","",function(str){//获取显示模式
       $("#loading").css({
           display:"none"
       });
       if(str.data!=undefined&&str.data.length>0){
           renderForm(str.data,"1","obj","select1",function(selectData){
               //finishedGoodDisplayMode=selectData;
           })
       }

   });
  //  $(".centerInput2").append(setInput("请输入显示模式","",50,"text"));
   document.body.onclick=function(){
       $(".selectedBox").css({
           "display":"none"
       })
       window.event? window.event.cancelBubble = true : e.stopPropagation();
   }
    $(".addCuloumn").click(function(){

        //indexNum=indexNum+1;
        $(".selectedBox p").remove();
        if(searchInputArr.length>0){
               var option="";
               for(var i=0;i<searchInputArr.length;i++){
                   option+='<p value="'+searchInputArr[i].className+'" >'+searchInputArr[i].title+'</option>'
               }
               $(".selectedBox").css({
                   "display":"block"
               }).append(option)
               $(".selectedBox p").click(function(){

                   $(".selectedBox").css({
                       "display":"none"
                   })
                   var text=$(this).text();
                   for(var i=0;i<searchInputArr.length;i++){
                       if(text==searchInputArr[i].title){
                           if(text=="模组产地"||text=="panel产地"||text=="显示模式"){
                               var oLi='<li><span class="title">'+searchInputArr[i].title+'：</span><span data-v="'+searchInputArr[i].dataV+'" class="centerInput '+searchInputArr[i].className+'"><form class="layui-form layform3" action=""> <div class="layui-form-item proSelect"> <div class="layui-input-block editWidth"> <select class="select1'+searchInputArr[i].dataV+'" name="" lay-verify="" lay-filter="select1"> <option value=""></option> </select> </div> </div></form></span><span><i title="删除" class="iconfont deleteItem">&#xe6ee;</i></span></li>';
                               goAjax(searchInputArr[i].dataV,oLi);
                               function goAjax(i,oLi){
                                   var url="/MaterialAttService";
                                   if(i=="moduleOrigin"){
                                        url+="/getModuleOrigin"
                                   }else if(i=="panelPlaceOfOrigin"){
                                       url+="/getPanelPlaceOfOrigin"
                                   }else if(i=="finishedGoodDisplayMode"){
                                       url+="/getFinishedGoodDisplayMode"
                                   }
                                   if(i=="moduleOrigin"){
                                       MaterialReverseAjax(url,"",function(str){//获取显示模式
                                           $("#loading").css({
                                               display:"none"
                                           });
                                           if(str.data!=undefined&&str.data.length>0){
                                               $(".seachHeader ul").append(oLi);
                                               renderForm(str.data,"1"+"moduleOrigin","obj","select1",function(selectData){
                                                  // mOData=selectData;
                                               })
                                           }
                                       })

                                   }else if(i=="panelPlaceOfOrigin"){
                                       MaterialReverseAjax(url,"",function(str){//获取显示模式
                                           $("#loading").css({
                                               display:"none"
                                           });
                                           if(str.data!=undefined&&str.data.length>0){
                                               $(".seachHeader ul").append(oLi);
                                               renderForm(str.data,"1"+"panelPlaceOfOrigin","obj","select1",function(selectData){
                                                  // panelPO=selectData;
                                               })
                                           }
                                       })
                                       //panelPO=selectData;
                                   }else if(i=="finishedGoodDisplayMode"){
                                       MaterialReverseAjax(url,"",function(str){//获取显示模式
                                           $("#loading").css({
                                               display:"none"
                                           });
                                           if(str.data!=undefined&&str.data.length>0){
                                               $(".seachHeader ul").append(oLi);
                                               renderForm(str.data,"1"+"finishedGoodDisplayMode","obj","select1",function(selectData){
                                                //   finishedGoodDisplayMode=selectData;
                                               })
                                           }
                                       })
                                       //finishedGoodDisplayMode=selectData;
                                   }

                               }
                           }else{
                               var oLi="<li><span class='title'>"+searchInputArr[i].title+"：</span><span data-v='"+searchInputArr[i].dataV+"' class='centerInput "+searchInputArr[i].className+"'></span><span><i title='删除' class='iconfont deleteItem'>&#xe6ee;</i></span></li>";
                               $(".seachHeader ul").append(oLi);
                               $('.'+searchInputArr[i].className+'').append(setInput(searchInputArr[i].holder,"",50,"text"));
                           }


                           focusOrBlur('.'+searchInputArr[i].className+'');
                           searchInputArr.splice(i,1);
                           var scrolltop=$(".formContent").scrollTop();
                           var searchHeaderHeight=$(".seachHeader").height()+32;
                           if(scrolltop>0){
                               $("#table2 table thead").css({
                                   "position":"fixed",
                                   "background":"#f2f2f2",
                                   "opacity":"1",
                                   "z-index": 1,
                                   "top":searchHeaderHeight+"px"
                               })
                           }else{
                               $("#table2 table thead").css({
                                   "position":""

                               })
                           }
                           var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
                           $(".formContent").css({
                               "max-height":heightform*0.85,
                               "overflow-y":"scroll"
                           });
                           if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                               $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
                           }else{
                               $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
                           }
                           return
                       }
                   }
               })
        }else{
            layerFn("暂无查询条件可以添加")
        }

        window.event? window.event.cancelBubble = true : e.stopPropagation();

    })

    var height=document.body.clientHeight;
    var width =document.body.clientWidth;
    $("#loading img").css({
        "margin-left":width/2-25+"px",
        "margin-top":height/2-25+"px"
    })
    focusOrBlur(".centerInput1");
    focusOrBlur(".centerInput2");
    $('.centerInput input').bind('keyup', function(event) {
        if (event.keyCode == "13") {
            //回车执行查询
            searchFn();
        }
    });
    function searchFn(){
        var obj={};
        for(var i=0;i<$("ul li").length;i++){
            if($("ul li").eq(i).find(".centerInput input").val()=="*"){
                layerFn("查询条件不能只填*，应填写例如：*TM01或者TM*");
                return;
            }
            var texts=$("ul li").eq(i).find(".title").text().split("：")[0];
            var val=$("ul li").eq(i).find("select option:selected").val();
            if(texts=="模组产地"||texts=="panel产地"||texts=="显示模式"){
               /* var mOData="";//模组产地选中下拉值
                var panelPO="";//panel产地下拉值
                var finishedGoodDisplayMode="";//显示模式下拉值*/
               if(texts=="模组产地"&&$("ul li").eq(i).length>0&&val){
                   obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]=val;
               }
                if(texts=="panel产地"&&$("ul li").eq(i).length>0&&val){
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]=val;
                }
                if(texts=="显示模式"&&$("ul li").eq(i).length>0&&val){
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]=encodeURIComponent(val);
                }

            }else if($("ul li").eq(i).find(".centerInput input").val()!=""&&$("ul li").eq(i).find(".centerInput input").val()!="*"){
                if($("ul li").eq(i).find(".centerInput").attr("data-v")=="panelPlaceOfOrigin"){
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]=$("ul li").eq(i).find(".centerInput input").val().replace(/\s+/g,"");
                }else{
                    obj[$("ul li").eq(i).find(".centerInput").attr("data-v")]= encodeURIComponent($("ul li").eq(i).find(".centerInput input").val().replace(/\s+/g,""));
                }

            }
        }
        if(JSON.stringify(obj)=="{}"){
            layerFn("查询条件不能全部为空");
            return;
        }
        var toFlage=false;
        for(var v in obj){
          if(obj[v]!=undefined&&obj[v]!=""){
             toFlage=true;
          }
        }
        if(toFlage){
            var url = "/FinishedGoodService/tmSearchFinishedGoodByAtt";
            // window.sqeExportExceldata=data;
            $("#loading").css({
                display:"block"
            });
            ajaxNewFn(url,obj,suCallback);
        }

    }

    $(".searchSureButton").click(function(){
        searchFn();
    })
    function suCallback(str){
        $(".formContent").empty();
        $("#loading").css({
            display:"none"
        });
            if(str!=undefined&&str.length>0){
                var dataListObjArr=[];
                for(var i=0;i<str.length;i++){
                    var dataListObj={};
                    dataListObj.number=str[i].number!=undefined?str[i].number:"";//成品编码
                    dataListObj.name=str[i].name!=undefined?str[i].name:"";//成品名称
                    dataListObj["cn.tianma.projectName"]=str[i]["cn.tianma.projectName"]!=undefined?str[i]["cn.tianma.projectName"]:"";//项目名称
                    dataListObj["cn.tianma.projectManager"]=str[i]["cn.tianma.projectManager"]!=undefined?str[i]["cn.tianma.projectManager"]:"";//项目经理
                    dataListObj.finishedGoodResolution=str[i].finishedGoodResolution!=undefined?str[i].finishedGoodResolution:"";//分辨率
                    dataListObj.finishedGoodLineBody=str[i].finishedGoodLineBody!=undefined?str[i].finishedGoodLineBody:"";//产品线
                    dataListObj.finishedGoodSize=str[i].finishedGoodSize!=undefined?str[i].finishedGoodSize:"";//产品尺寸
                    dataListObj.finishedGoodDisplayMode=str[i].finishedGoodDisplayMode!=undefined?str[i].finishedGoodDisplayMode:"";//显示模式
                    dataListObj.finishedGoodMaskNumber=str[i].finishedGoodMaskNumber!=undefined?str[i].finishedGoodMaskNumber:"";//Mask张数
                    dataListObj.finishedGoodModel =str[i].finishedGoodModel!=undefined?str[i].finishedGoodModel:"";//,"Model"
                    dataListObj.finishedGoodLCDArrangement=str[i].finishedGoodLCDArrangement!=undefined?str[i].finishedGoodLCDArrangement:"";//LCD排版数
                    dataListObjArr.push(dataListObj);
                }
                var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
                $(".formContent").css({
                    "max-height":heightform*0.85,
                    "overflow-y":"scroll"
                });
                window.historyList1 =dataListObjArr;
                window.headers1= ["序号","成品编号","成品名称","项目名称","项目经理","分辨率","产品线","产品尺寸","显示模式","Mask张数","Model","LCD排版数"] //table的列名
                window.widths1 = ['100',"200","200","100","100","100","100","100","100","100","100"]//table每列的宽度
                $(".formContent").empty().load('./newTable.html',"",function(){
                    setTimeout(function(){
                        var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;

                        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
                            $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
                        }else{
                            $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
                        }
                        $("#pageBar2").css("display","block");
                        $(".formContent").css({
                            "max-height":heightform*0.85,
                            "overflow-y":"scroll"
                        });
                        clearTimeout();
                    },200)
                });
            }else{
                layerFn("查询数据不存在");
            }
    }
   $(".formContent").scroll(function() {
       var scrolltop=$(this).scrollTop();
        var searchHeaderHeight=$(".seachHeader").offsetHeight;
       if(scrolltop>0){
           $("#table2 table thead").css({
               "position":"absolute",
               "background":"#f2f2f2",
               "opacity":"1",
               "z-index": 1,
               "top":searchHeaderHeight+"px"
           })
       }else{
           $("#table2 table thead").css({
               "position":""

           })
       }
       for (var i = 0; i <  window.headers1.length; i++) {
           var width = $("#table2 table tbody tr:first-child td").eq(i).width();
           if(IEVersion()>(8)){
               $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                   "width": width-0.1
               })
           }else{
               $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                   "width": width+0.3
               })
           }

       }
   })
   $(window).resize(function () { //当浏览器大小变化时
       //console.log($("#table2 table").width())
       $("#table2 table thead tr").css({
           "width":$("#table2 table").width()

       })
       var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
       $(".formContent").css({
           "max-height":heightform*0.85,
           "overflow-y":"scroll"
       });
       if($(".formContent")[0].offsetHeight>(heightform*0.85)){
           $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
       }else{
           $("#pageBar2").css("top",$(".formContent")[0].offsetHeight+$(".seachHeader").height()+40);
       }
       for (var i = 0; i <  window.headers1.length; i++) {
           var width = $("#table2 table tbody tr:first-child td").eq(i).width();
           if(IEVersion()>(8)){
               $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                   "width": width-0.1
               })
           }else{
               $("#table2 .layui-table thead tr:first-child th").eq(i).css({
                   "width": width+0.5
               })
           }

       }
   });

    $("body").unbind().on("click",'.deleteItem',function(){
        var title=$(this).parents("li").find(".title").text().split("：")[0];
        var holder=title;
        var className=$(this).parents("li").find("span").eq(1).attr("class").split(" ")[1];
        var dataV=$(this).parents("li").find("span").eq(1).attr("data-v");
        if(dataV=="moduleOrigin"||dataV=="panelPlaceOfOrigin"||dataV=="finishedGoodDisplayMode"){

        }else{
            holder= $(this).parents("li").find("label").text()
        }
        var obj={//添加搜索条件
            title:title,
            className:className,
            dataV:dataV,
            holder:holder
        };
        var index=getIndexof(searchInputArr,obj);
        if(index==(-1)){
            searchInputArr.push(obj)
        }
        $(this).parents("li").remove();
        var scrolltop=$(".formContent").scrollTop();
        var searchHeaderHeight=$(".seachHeader").height()+32;
        if(scrolltop>0){
            $("#table2 table thead").css({
                "position":"absolute",
                "background":"#f2f2f2",
                "opacity":"1",
                "z-index": 1,
                "top":searchHeaderHeight+"px"
            })
        }else{
            $("#table2 table thead").css({
                "position":""

            })
        }
        var heightform=$(".searchContainer").height()-$(".seachHeader").height()-20;
        $(".formContent").css({
            "max-height":heightform*0.85,
            "overflow-y":"scroll"
        });
        if($(".formContent")[0].offsetHeight>(heightform*0.85)){
            $("#pageBar2").css("top",heightform*0.85+$(".seachHeader").height()+30)
        }else{
            $("#pageBar2").css("bottom",20);
        }
    })
</script>
</html>